#pragma once
#include <cstdint>
#include <memory>
#include <mutex>

namespace xncc {
namespace shared {
    template <typename T, uint8_t INST_ID = 0>
    class Singleton
    {
      public:
        static T& inst()
        {
            static std::unique_ptr<T> instance;
            static std::once_flag     flag;
            std::call_once(flag, [] { instance.reset(new T()); });
            return *instance;
        }

        Singleton()  = delete;
        ~Singleton() = delete;

        Singleton(const Singleton&) = delete;

        Singleton& operator=(const Singleton&) = delete;

        Singleton(Singleton&&) = delete;

        Singleton& operator=(Singleton&&) = delete;
    };
}  // namespace shared
}  // namespace xncc